package com.newtouch.bxzs.database.synchronize.batch.process;

import com.newtouch.bxzs.common.base.model.CooperationCompanyUser;
import com.newtouch.bxzs.common.base.util.PinYinUtils;
import com.newtouch.bxzs.database.synchronize.model.UserBO;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 用户同步数据处理
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021/1/7 10:56</td>
 * <td>Amour</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author yuanjie
 * @version 1.0.0
 * @since 1.0.0
 */
@Component
public class ProcesorSystemUser {

    /**
     * 处理合作公司用户信息
     * @return ItemProcessor
     */
    public ItemProcessor<UserBO, CooperationCompanyUser> processorCooperationUser(){
        return userBO -> {
            //处理数据
            CooperationCompanyUser user = new CooperationCompanyUser();
            user.setCooperationCompanyUserJobNumber(userBO.getUserJobNumber());
            user.setCooperationCompanyUserName(userBO.getUserName());
            user.setCooperationCompanyUserSex(userBO.getUserSex());
            user.setCooperationCompanyUserPhone(userBO.getUserPhone());
            user.setCooperationCompanyUserCertificateType(userBO.getUserCertificateType());
            user.setCooperationCompanyUserCertificateNumber(userBO.getUserCertificateNumber());
            user.setCooperationCompanyUserEntryTime(userBO.getUserEntryTime());
            user.setCooperationCompanyUserWorkingStatus(userBO.getUserWorkingStatus());
            user.setCooperationCompanyUserAddress(userBO.getUserAddress());
            user.setCooperationCompanyUserOrganizationName(userBO.getUserOrganizationName());
            user.setCooperationCompanyUserOrganizationCode(userBO.getUserOrganizationCode());
            user.setCooperationCompanyUserDepartmentName(userBO.getUserDepartmentName());
            user.setCooperationCompanyUserIntroduction(userBO.getUserIntroduction());
            user.setCooperationCompanyUserBirthday(userBO.getUserBirthday());
            user.setCooperationCompanyUserEmail(userBO.getUserEmail());
            user.setCreateUserId("admin");
            user.setCreateTime(new Date());
            user.setCooperationCompanyUserNameFullSpelling(PinYinUtils.toPinyin(userBO.getUserName()));
            return user;
        };
    }


}
